package BuddyTemplate;

/* Team Directories
 *
 * You are free to do whatever you want with this code. Frankly we don't give a damn.
 * 
 *  
 * Copyright GNU General Public License v3
 */

/**
 *
 * @author Gabriel
 */

import java.util.*;

public class Question <QuestionType, AnswerType> {
    
    QuestionType question;
    int questionnumber = 0;
    public ArrayList<AnswerType> choices = new ArrayList<AnswerType>(); //An arraylist of question choices
    ArrayList<Boolean> answers = new ArrayList<Boolean>(); //Answers (An Arraylist)
    int difficulty;
    
    public Question(){
        
        // Default Constructor
        
    }
    
    public void setDifficulty(int theDifficulty){
        
        difficulty = theDifficulty;
        
    }
    
    public void setQuestion(QuestionType thequestion){
        
        /* This is quite self-explaniatory, the question is being set here.*/
        
        question = thequestion;
        
    }
    
    public void setChoice(AnswerType thechoices, Boolean theanswers){
        
        /* This function sets the Choices
         * Choices and answers are set at the same time
         * so that there are a same number of questions and answers
         */
        
        choices.add(thechoices);
        answers.add(theanswers);
        questionnumber ++;
        
            
    }
    
    public int checkAnswers(ArrayList<Boolean> answersprovided){
        
        /* This function is implemented to check the Answers to the questions
         * The scoring method used is as such - there are a total of n checkboxes
         * for each checkbox which is ticked correctly, the score increases by one
         * otherwise the score decreases by one. If there are 4 choices, for example,
         * then a perfect score would be 4. If he checked everything except the right
         * answers, then the score would be -4 
         */
        
        int score = 0;      
        
        
        for(int i = 0; i < questionnumber; i++){
            
            if (answersprovided.get(i).booleanValue() == answers.get(i).booleanValue())
            {
                score ++;
            } 
            
            else 
            {
                score --;
            }
        }
        
        return score * 4/questionnumber;
        
    }    
    
    public Object getChoices(){
        
        return choices;
        
    }
    
    public QuestionType getQuestion(){
        
        return question;
        
    }    
    

}
